<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<title></title>
</head>
<link rel="stylesheet" href="./style.css/repassword.css">
<link rel="stylesheet" href="./font_78xmwrbhrzu/iconfont.css">
<script src="./js/Cook.js"></script>

<body>
	<div id="header">
		<div></div>
		<div id="header_left">
			<div id="helper">帮助中心</div>
			<div id="languge">简体中文</div>
		</div>
	</div>
	<h1>修改密码</h1>
	<form action="get">
		<div id="content">
			<div id="tree">
				<input type="password" id="pwd1" placeholder="原密码" />
			</div>
			<div id="five" style="font-size: 30px;" class="iconfont icon-Notvisible">
				<input type="password" placeholder="新密码" id="pwd">
			</div>
			<span>密码由 6-16 位数字、字母或符号组成、至少包含两种字符</span>
			<div style="background-color: #fff;">
				<input type="button" id="submit" name="" value="下一步" />
			</div>
	</form>
	</div>
	<div id="bottom">
		<p>© 2005 - 2022 广东欢太 版权所有 粤ICP备 14056724 号-2 联系方式：4001-999-666</p>
	</div>
	<script src="./js/_ajax.js"></script>
	<script>
		const pwd1 = document.querySelector("#pwd1")
		const submit = document.querySelector("#submit")
		const eye = document.getElementsByClassName("iconfont")[0];
		const pwd = document.getElementById("pwd");
		var flag = 0;

		var Cook = getCookie("users")
		ajax({
			type: "get",
			url: "http://localhost:3000/myself?id=" + Cook,
			success: res => {
				console.log(res)
				if (JSON.parse(res).code != 0) {
					location.href = "http://localhost:3000/login.html"
				}
			},
			error: code => {
				console.log("error", code);
			}
		})








		eye.onclick = function () {
			if (flag == 0) {
				pwd.type = "password";
				eye.className = "iconfont icon-browse"
				flag = 1;

			} else {
				pwd.type = "text";
				eye.className = "iconfont icon-Notvisible"
				flag = 0;
			}
		}

		submit.onclick = function () {
			if (pwd.value == "") {
				console.log("新密码不能为空")
				return
			}
			// console.log("11")
			ajax({
				type: "get",
				url: "http://localhost:3000/repassword",
				data: {
					p1: pwd1.value,
					p2: pwd.value,
					setpwd: Cookpwd,
				},
				success: res => {
					console.log("success", res)
				},
				error: code => {
					console.log("error", code)
				}
			})

		}


	</script>
</body>

</html>